﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Threading;
//using System.Threading.Tasks;
//using Volo.Abp.EntityFrameworkCore;
//using Xms.Abp.Storage;

//namespace PermissionManagement.Storage;

//public class PermissionGrantRepository : XmsStorageRepository<IPermissionManagementStorage, PermissionGrant, Guid>,
//    IPermissionGrantRepository
//{
//    public PermissionGrantRepository(IDbContextProvider<IPermissionManagementStorage> dbContextProvider)
//        : base(dbContextProvider)
//    {

//    }

//    public virtual async Task<PermissionGrant> FindAsync(
//        string name,
//        string providerName,
//        string providerKey,
//        CancellationToken cancellationToken = default)
//    {
//        return await (await GetDbSetAsync())
//            .OrderBy(x => x.Id)
//            .FirstOrDefaultAsync(s =>
//                s.Name == name &&
//                s.ProviderName == providerName &&
//                s.ProviderKey == providerKey,
//                GetCancellationToken(cancellationToken)
//            );
//    }

//    public virtual async Task<List<PermissionGrant>> GetListAsync(
//        string providerName,
//        string providerKey,
//        CancellationToken cancellationToken = default)
//    {
//        return await (await GetDbSetAsync())
//            .Where(s =>
//                s.ProviderName == providerName &&
//                s.ProviderKey == providerKey
//            ).ToListAsync(GetCancellationToken(cancellationToken));
//    }

//    public virtual async Task<List<PermissionGrant>> GetListAsync(string[] names, string providerName, string providerKey,
//        CancellationToken cancellationToken = default)
//    {
//        return await (await GetDbSetAsync())
//            .Where(s =>
//                names.Contains(s.Name) &&
//                s.ProviderName == providerName &&
//                s.ProviderKey == providerKey
//            ).ToListAsync(GetCancellationToken(cancellationToken));
//    }
//}
